<?php
/*
 * Session variables:
 * $_SESSION['database'] [string] = database name of the current tutorial centre
 * $_SESSION['type'] [string] = user type of the logged in user
 * $_SESSION['authorised'] [boolean] = whether or not the current user is logged in
 * $_SESSION['user'] [string] = the username/ email of the logged in user
 * $_POST['audibility'] [int]
 * $_POST['manner_of_teaching'] [int]
 * $_POST['materials_used'] [int]
 * $_POST['preparedness'] [int]
 * $_POST['subject_mastery'] [int]
 */
session_start();

if(isset($_SESSION['authorised']) && $_SESSION['authorised'] == true) {
	if(isset($_SESSION['type'])) {
		if($_SESSION['type'] == 'administrator') {
			header('Location: admin_index.php');
			exit();
		}
		elseif($_SESSION['type'] == 'student') {
			include('connection.inc');
			?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<style>
.nav {
	width: 210px;
	height: auto;
	border: thin solid #09C;
	margin-left: 10px;
	text-align: center;
}

.mainline {
	width: 712px;
	height: auto;
	text-align: center;
}
</style>
</head>
<body bgcolor="#FFFFFF">
	<center>

		<div id="wrapper">
			<div id="header">
				<h1></h1>
			</div>

			<div id="header2">
				<h3></h3>
			</div>

			<div id="nav">
				<?php include 'student_navigation.php';?>
			</div>

			<div id="mainline">
				<h4>Tutor Evaluation - 1 of 2</h4>
				<div id="body">
				<form action="student_evaluatetutor2.php" method="post">
					<table height="auto">
						<tr>
							<th align="left">Tutor's Name:</th>
							<td><select name="tutor">
							<?php
							$username = $_SESSION['user'];
							$sql = "SELECT * FROM students where username = '$username';";
							$result = pg_query($sql);
							$studentid = pg_fetch_result($result, 0, 'student_id');
							for ($i = 0; $i < pg_num_rows($result); $i++) {
								$sql = "SELECT * FROM enrolled_at NATURAL INNER JOIN teachers NATURAL INNER JOIN users where student_id = $studentid;";
								$result2 = pg_query($sql);
								$teacher_first_name = pg_fetch_result($result2, $i, 'firstname');
								$teacher_last_name = pg_fetch_result($result2, $i, 'lastname');
								$teacher_id = pg_fetch_result($result2, $i, 'teacher_id');
								$teacher_name = $teacher_first_name . " " . $teacher_last_name;
								echo "<option value = \"$teacher_id\">$teacher_name</option>";
							}
							?>
							</select>
							</td>
						</tr>
					</table>
					
						<table width="700" align="center">
							<tr bgcolor="e8e8e8">
								<th align="left" width="200">Field</th>
								<?php
								for ($i = 1; $i <= 5; $i++) {
									echo '<th width="100">'. $i. '</th>';
								}
								?>
							</tr>
							<tr bgcolor="#f5f5f5">
								<th align="left">Audibility</th>
								<?php
								for ($i = 1; $i <= 5; $i++) {
									echo '<td align="center">'."<input type=\"radio\" name=\"audibility\" value=\"$i\"/></td>";
								}
								?>
							</tr>
							<tr bgcolor="e8e8e8">
								<th align="left">Manner of Teaching</th>
								<?php
								for ($i = 1; $i <= 5; $i++) {
									echo '<td align="center">'."<input type=\"radio\" name=\"manner_of_teaching\" value=\"$i\"/></td>";
								}
								?>
							</tr>
							<tr bgcolor="#f5f5f5">
								<th align="left">Mastery of Subject Area</th>
								<?php
								for ($i = 1; $i <= 5; $i++) {
									echo '<td align="center">'."<input type=\"radio\" name=\"subject_mastery\" value=\"$i\"/></td>";
								}
								?>
							</tr>
							<tr bgcolor="e8e8e8">
								<th align="left">Materials Used</th>
								<?php
								for ($i = 1; $i <= 5; $i++) {
									echo '<td align="center">'."<input type=\"radio\" name=\"materials_used\" value=\"$i\"/></td>";
								}
								?>
							</tr>
							<tr bgcolor="#f5f5f5">
								<th align="left">Preparedness</th>
								<?php
								for ($i = 1; $i <= 5; $i++) {
									echo '<td align="center">'."<input type=\"radio\" name=\"preparedness\" value=\"$i\"/></td>";
								}
								?>
							</tr>
							<tr>
								<th align="left">
									<input name="submit" type="submit" value="Submit" />
								</th>
							</tr>
						</table>
					</form>
				</div>
			</div>

			<br class="clearfloat"> <br />

			<div id="footer">
				<p align="center">
					Tutorial Business Manager: info@tbms.com <br />Credits/Engineers:
					Aquino, Chloebelle; Dela Cruz, Roy Erwin; Maliwanag, Ranyel Bryan;
					Manzano, Audrey Ann; Ng, Sheila Regine<br /> <br />copyright 2011
				</p>
			</div>
		</div>
	</center>
</body>
</html>
								<?php
		}
		elseif($_SESSION['type'] == 'tutor') {
			header('Location: tutor_index.php');
			exit();
		}
		elseif($_SESSION['type'] == 'parent') {
			header('Location: parent_index.php');
			exit();
		}
	}
}
else {
	header('Location: index.php');
}
?>